from flask import Flask
import config
from apps.user.view import user_bp
from apps.data.view import data_bp
from exts import db

def create_app():  # 工厂模式
    app = Flask(__name__, template_folder='../templates', static_folder='../static')  # app是一个核心对象
    app.config.from_object(config.DevConfig)  # 加载配置
    db.init_app(app)  # 将你的flask对象与SQLAlchemy功能关联
    app.register_blueprint(user_bp)  # 注册蓝图，将蓝图对象绑定到app上
    app.register_blueprint(data_bp)
    print(app.url_map)
    return app
